package com.fei.wechat.admin.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.fei.wechat.admin.aspect.annotation.AnnoOperateLog;
import com.fei.wechat.common.constant.Constants;
import com.fei.wechat.common.constant.OperateLogConstant;
import com.fei.wechat.common.constant.OperateLogContentTemplate;
import com.fei.wechat.common.controller.admin.BaseController;
import com.fei.wechat.common.model.vo.RespVo;
import com.fei.wechat.middlewar.mode.bo.admin.LoginBo;
import com.fei.wechat.middlewar.mode.vo.admin.CurrentUser;

/**
 * 描述: 登录控制层
 * 版权: Copyright (c) 2018 
 * 公司: 飞翔科技 
 * 作者: 张进飞 
 * 版本: 1.0 
 * 创建日期: 2018年3月5日 
 * 创建时间: 下午11:09:46
 */
@Controller
@RequestMapping("/admin/login")
public class LoginController extends BaseController
{
    
    /**
     * 描述：index页面
     * 作者：张进飞
     * 时间：2018年3月10日 上午11:47:47
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public ModelAndView index(HttpServletRequest request, HttpServletResponse response)
    {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("index");
        return mav;
    }
    
    /**
     * 描述：登录提交方法
     * 作者：张进飞
     * 时间：2018年4月22日 下午8:30:51
     * @return
     */
    @AnnoOperateLog(moduleName = OperateLogConstant.MODULE_INDEX, function = OperateLogConstant.MODULE_INDEX, operateType = OperateLogConstant.OPERATE_ID_LOGIN, operateContentTemplate = OperateLogContentTemplate.LOGIN_USER)
    @RequestMapping(value = "/loginSubmit", method = RequestMethod.POST)
    public RespVo loginSubmit(LoginBo LoginBo, HttpServletRequest request)
    {
        RespVo respVo = new RespVo();
        CurrentUser currentUser = new CurrentUser();
        request.getSession().setAttribute(Constants.USER_LOGIN_FLAG, currentUser);
        Object[] logArgs = new Object[] { currentUser.getUser().getLoginName(), currentUser.getUser().getLoginName(), "成功" };
        respVo.setLogArgs(logArgs);
        return respVo;
    }
}
